import {defineConfig} from "@rsbuild/core";
import {pluginVue} from "@rsbuild/plugin-vue";
import {resolve} from "path";

function pathResolve(dir: string) {
    return resolve(process.cwd(), ".", dir);
}

export default defineConfig({
    plugins: [pluginVue()],
    server: {
        port: 3001,
        open: true,
        proxy: {
            "/apple": {
                target: "http://localhost:3000/",
                changeOrigin: true,
                // pathRewrite: {"^/api": ""},
            },
        },
    },
    source: {
        alias: {
            "/@": pathResolve("src") + "/",
        },
    },
    output: {
        filename: {
            html: "[name].html",
            js:
                process.env.NODE_ENV === "production"
                    ? "[name]_script.[contenthash:8].js"
                    : "[name]_script.js",
        },
    },
    html: {
        title: "PARK",
        appIcon: {
            name: "PARK",
            icons: [{src: "./src/assets/park.png", size: 192}],
        },
        favicon: "./src/assets/park.png",
    },
});
